package com.example.rabbitmq.demo2_pub_confirm;

import com.example.rabbitmq.demo3_backup_exchange.BackupConfig;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author songyahui
 * @Date 2023/7/12 17:44
 * @Description
 */
@Configuration
public class ConfirmConfig {
    //-----------------------------------------------发布确认配置----------------------------------------
    //交换机
    public static final String CONFIRM_EXCHANGE_NAME = "confirm_exchange";

    //队列
    public static final String CONFIRM_QUEUE_NAME = "confirm_queue";

    //routing key
    public static final String CONFIRM_ROUTING_KEY = "confirm_routing_key";

    //声明交换机
//    创建发布确认交换机
//    @Bean("confirmExchange")
//    public DirectExchange confirmExchange(){
//        return new DirectExchange(CONFIRM_EXCHANGE_NAME);
//    }

    @Bean("confirmQueue")
    public Queue confirmQueue(){
        return QueueBuilder.durable(CONFIRM_QUEUE_NAME).build();
    }

    @Bean
    public Binding queueBindingExchange(@Qualifier("confirmQueue") Queue confirmQueue, @Qualifier("confirmExchange") DirectExchange exchange){
        return BindingBuilder.bind(confirmQueue).to(exchange).with(CONFIRM_ROUTING_KEY);
    }



}
